package untiring.controllers;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import untiring.interfaces.MemberService;
import untiring.interfaces.OrderService;
import untiring.interfaces.ProductService;
import untiring.models.BoardVO;
import untiring.models.CartVO;

@Controller
public class OrderController {
	
	@Autowired
	private MemberService memberService;
	@Autowired
	private ProductService productService;
	@Autowired
	private OrderService orderservice;
	
	@RequestMapping(value="/mypage/myorder", method = RequestMethod.GET)
	public String tman(Model model) throws Exception{
		model.addAttribute("product", productService.readProduct());
		return "man/tlist";
	}

	@RequestMapping(value="/man/view",	method=RequestMethod.POST)
	public String insertcartpost(@ModelAttribute CartVO c) throws Exception {
		return orderservice.newCart(c);
	}
	
	@RequestMapping(value="/mypage/mycart", method = RequestMethod.GET)
	public String readcart(Model model) throws Exception{
		model.addAttribute("cart", orderservice.readCart());
		return "/mypage/mycart";
	}
	
}
